<%--
  User: Bear
  Date: 2020/10/5
  Time: 15:12
--%>
<%@ page contentType="text/html; charset=utf-8"
         pageEncoding="utf-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
    <title>分页</title>
</head>
<body>


<div>

    <nav aria-label="Page navigation">
        <ul class="pagination">
            <%--第一页--%>
            <%--如果是第一页，显示disabled--%>
            <c:if test="${pageBean.currentPage ==1}">
            <li class="disabled">
                <a href="#" aria-label="Previous">
                    </c:if>

                    <%--如果不是是第一页，不显示disabled--%>
                    <c:if test="${pageBean.currentPage !=1}">
            <li>

                <a href="${pageBean.url}&pageSize=4&currentPage=${pageBean.currentPage - 1}" aria-label="Previous">

                    </c:if>

                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
            <%--中间页--%>
            <c:forEach begin="1" end="${pageBean.totalPage}" var="i">
                <%--如果当前页等于第i页，页码激活状态--%>
                <c:if test="${pageBean.currentPage ==i}">
                    <li class="active"><a href="${pageBean.url}&pageSize=4&currentPage=${i}">${i}</a></li>
                </c:if>
                <%--如果当前页等于第i页，页码没有激活状态--%>
                <c:if test="${pageBean.currentPage !=i}">
                    <li><a href="${pageBean.url}&pageSize=4&currentPage=${i}">${i}</a></li>
                </c:if>

            </c:forEach>

            <%--最后一页--%>
            <%--如果当前页等于最后页，显示disabled，a标签取消href属性--%>
            <c:if test="${pageBean.currentPage ==pageBean.totalPage}">
            <li class="disabled">
                <a href="#" aria-label="Previous">
                    </c:if>

                    <%--如果当前页不等于最后页，不显示disabled，a标签href属性指向下一页--%>
                    <c:if test="${pageBean.currentPage !=pageBean.totalPage}">
            <li>
                <a href="${pageBean.url}&pageSize=4&currentPage=${pageBean.currentPage + 1}" aria-label="Next">

                    </c:if>

                    <span aria-hidden="true">&raquo;</span>
                </a>

            </li>
            <span style="font-size: 26px;margin-left: 10px">
                    共${pageBean.totalCount}条记录，共${pageBean.totalPage}页
                </span>
        </ul>
    </nav>

</div>

</body>
</html>
